﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x0200003E RID: 62
	public class NullableUInt64Formatter : IMessagePackFormatter<ulong?>
	{
		// Token: 0x060000E7 RID: 231 RVA: 0x00004534 File Offset: 0x00002934
		private NullableUInt64Formatter()
		{
		}

		// Token: 0x060000E8 RID: 232 RVA: 0x0000453C File Offset: 0x0000293C
		public int Serialize(ref byte[] bytes, int offset, ulong? value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteUInt64(ref bytes, offset, value.Value);
		}

		// Token: 0x060000E9 RID: 233 RVA: 0x00004564 File Offset: 0x00002964
		public ulong? Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new ulong?(MessagePackBinary.ReadUInt64(bytes, offset, out readSize));
		}

		// Token: 0x04000032 RID: 50
		public static readonly NullableUInt64Formatter Instance = new NullableUInt64Formatter();
	}
}
